package com.woniuxy.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.entity.ArticleLike;
import com.woniuxy.core.service.ArticleLikeService;
import com.woniuxy.core.mapper.ArticleLikeMapper;
import org.springframework.stereotype.Service;

/**
* @author 35123
* @description 针对表【article_like(帖子点赞关联表)】的数据库操作Service实现
* @createDate 2025-07-11 12:21:53
*/
@Service
public class ArticleLikeServiceImpl extends ServiceImpl<ArticleLikeMapper, ArticleLike>
    implements ArticleLikeService{
    @Override
    public Long countLikesByTargetIdAndType(Long targetId, Integer targetType) {
        return this.count(new QueryWrapper<ArticleLike>()
                .eq("target_id", targetId)
                .eq("target_type", targetType)
                .eq("status", 1)); // 只统计点赞状态
    }
    @Override
    public Long countLikesByArticleId(Long articleId) {
        return this.count(new QueryWrapper<ArticleLike>()
                .eq("target_id", articleId)
                .eq("target_type", 1) // 固定为帖子类型
                .eq("status", 1)); // 只统计点赞状态
    }

}




